import { h } from 'vue';

const AIcon = {
  name: 'AIcon',
  displayName: 'AIcon',
  props: {
    src: [Object, String, Function],
  },
  setup(props, { attrs }) {
    const src = props.src;
    const style = { width: '1em', height: '1em' };
    return () => {
      const isStr = typeof src === 'string' && src;
      return isStr ? h('img', { src, style, ...attrs }, null) : src ? h(src, { style, ...attrs }) : null;
    };
  },
};

AIcon.install = (app) => {
  app.component(AIcon.name, AIcon);
};

export default AIcon;
